package com.boco.blch.analysiser.compliance.HW.data;

import org.springframework.util.StringUtils;

import com.boco.blch.analysiser.compliance.ComplianceResolved;
import com.boco.blch.analysiser.util.XmlUtil;

/**
 * @author 黄戈
 * HBaseHBase用户访问权限控制安全基线要求项--控制节点
 *
 */
public class BOCO_Hbase_VisitCtl_UserVisitCtl implements ComplianceResolved {

	
	private final static String HbaseP1 ="hbase.security.authorization";
	private final static String HbaseP2="hbase.coprocessor.region.classes";
	private final static String HbaseP3="hbase.coprocessor.master.classes";
	private final static String HbaseP4="hbase.superuser";
	private final static String HbaseR1="org.apache.hadoop.hbase.security.access.AccessController";


	@Override
	public int realEchoResolved(String echoResult) {
		if(!echoResult.equals("")&&echoResult!= null&&(!echoResult.contains(NoPermission1)&&!echoResult.contains(NoPermission2)&&!echoResult.contains(NoPermission3))){
		String DataResult=echoResult;//.substring(echoResult.indexOf("Data-start")+"Data-start".length(),echoResult.indexOf("Data-end")).trim();
		if(!DataResult.contains(NotFindFile)&&!echoResult.contains("boco-HBase-result:error")){
		String HbaseResult1=XmlUtil.getValueByName(DataResult,HbaseP1);
		String HbaseResult2=XmlUtil.getValueByName(DataResult,HbaseP2);
		String HbaseResult3=XmlUtil.getValueByName(DataResult,HbaseP3);
		String HbaseResult4=XmlUtil.getValueByName(DataResult,HbaseP4);
		if(HbaseResult1.equals("true")&&HbaseResult2.contains(HbaseR1)&&HbaseResult3.contains(HbaseR1)&&(!HbaseResult4.equals("null")&&HbaseResult4!=null&&!StringUtils.isEmpty(HbaseResult4))){
			return SUCCESS;
		}else{
			return FAILED;
		}
	
	  }else{
		  return FAILED;
	  }
		}else{
		return FAILED;	
		
		}
	}
	
	/*
*/

}
